home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PsL Monthly 1993 December
/
PSL Monthly Shareware CD-ROM (December 1993).iso
/
prgmming
/
dos
/
c
/
stdlib1.exe
/
lha
/
STRCHR.ASM
< prev
next >
Wrap
Assembly Source File
|
1990-07-14
|
856b
|
60 lines
stdlib segment para public 'slcode'
assume cs:stdlib
;
;
; strchr- Returns the position of a single character in a string.
;
; inputs:
;
; al- character to search for.
; es:di- address of string.
;
; returns:
;
; cx- position of character in string (if present).
; carry=0 if character found.
; carry=1 if character is not present in string.
;
public sl_strchr
;
sl_strchr proc far
pushf
push ds
push si
push ax
cld
;
mov si, es ;Setup ds:si to use LODSB
mov ds, si
mov si, di
;
mov ah, al ;ah=char to search for.
strchrlp: lodsb
cmp al, ah
jz FndChr
cmp al, 0
jne strchrlp
;
xor cx, cx
pop ax
pop si
pop ds
popf
stc
ret
;
FndChr: pop ax
mov cx, si
sub cx, di
dec cx
pop si
pop ds
popf
clc
ret
sl_strchr endp
;
;
stdlib ends
end